@extends('web.layouts.app')

@section('styles')
    <link rel="stylesheet" type="text/css" href="{{ asset('resources/web/css/index.css') }}">
    <link rel="stylesheet" type="text/css" href="{{ asset('resources/web/css/ucenter.css')}}">
@endsection

@section('content')
    <div class="uc-wrap swrap mt20">
        <div class="uc-side L">
            <div class="uc-nav">
                <ul>
                    @include('web.user_center.menu')
                </ul>
            </div>
        </div>
        <div class="uc-main uc-mainbg R" >
            <!--用户信息-->
            <div class="user-main-bar">
                <div class="user-info">
                    <p class="tips">
                        @if(date('G')<11)
                            早上好
                            @elseif(date('G')<13)
                            中午好
                            @elseif(date('G')<17)
                            下午好
                            @else
                            晚上好
                            @endif, {{ $user->userInfo->name??$user->username}} 欢迎回来！</p>
                            <!-- 机构用户 -->
                    @if($user->hasRole('OperatingPlatform') || $user->hasRole('GuaranteeAgency') || $user->hasRole('MarketingAgency'))
                        <div class="items">
                            <span class="item">企业用户名：{{ $user->username }}</span><i>|</i>
                                <span class="item">认证：<em class="onid"></em><em class="ontel"></em><em class="onemail"></em></span><i>|</i>
                            <span class="item">支付账户：{{ $user->identity_id }} </span>
                            <!-- <a class="goactive" href="#">立即激活</a> -->
                        </div>
                    @else
                        <div class="items">
                            <span class="item">用户名：{{ $user->username }}</span><i>|</i>
                                <span class="item">认证：<em class="{{ $user->isSetRealName()?'onid':'id' }}"></em><em class="{{ $user->isBindingPhoneNumber()?'ontel':'tel' }}"></em><em class="{{ $user->isBindingEmail()?'onemail':'email' }}"></em></span><i>|</i>
                            <span class="item">支付账户：{{ $user->identity_id }} </span>
                            <!-- <a class="goactive" href="#">立即激活</a> -->
                        </div>
                    @endif
                </div>
            </div>
            <!--用户资产-->
            <div class="user-capital clearfix">
                <dl class="brow-total">
                    <dt>累计收益</dt>
                    <dd>{{$user->accumulatedIncome()}}</dd>
                </dl>
                <ul class="item-list">
                    <li>账户总额<span>{{ $user->allMoney() }}</span>元</li>
                    <li>可用总额<span>{{ $user->availableMoney() }}</span>元</li>
                    <li>存钱罐收益<span>{{ $user->bonus() }}</span>元<i class="abc-title">?
                <div class="abc-box"><div class="angur"></div>由新浪“微财富”平台推出的一款名为“存钱罐”的账户余额增值产品</div></i></li>
                    <li>待收总额<span>{{ $user->collectionMoney() }}</span>元</li>
                </ul>
                <ul class="item-list">
                    <li>冻结总额<span>{{ $user->frozenMoney() }}</span>元</li>
                    <li>充值总额<span>{{ $user->rechargeMoney() }}</span>元</li>
                    <li>投资总额<span>{{ $user->investmentMoney()  }}</span>元</li>
                    @if($user->hasRole('loaner') || $user->hasRole('Agent') || $user->hasRole('OperatingPlatform') || $user->hasRole('GuaranteeAgency') || $user->hasRole('MarketingAgency'))
                        <li>基本户<span>
                        <a style="color:#f0893e;" href="{{ action('UserCenter\UserCenterController@transferToSavingPot',['id'=>$user->id]) }}" title="转入存钱罐" alt="转入存钱罐">{{ $user->basicMoney()  }}</a></span>元<i class="abc-title">?
                <div class="abc-box"><div class="angur"></div>还款金额将还到基本户，需转入存钱罐方可操作投资提现<a style="text-decoration:underline;" href="{{ action('UserCenter\UserCenterController@transferToSavingPot',['id'=>$user->id]) }}" >转入存钱罐</a></div></i><a style="text-decoration:underline;color:#f0893e;" href="{{ action('UserCenter\UserCenterController@transferToSavingPot',['id'=>$user->id]) }}" >转入存钱罐</a></li>
                    @endif

                </ul>
                <div class="do">
                    <a class="cz" href="{{ action('UserCenter\UserCenterController@recharge') }}">充值</a>
                    <a href="{{ action('UserCenter\UserCenterController@withdraw') }}">提现</a>
                </div>
            </div>
            <!--融资列表-->
            <div class="user-item-list pt20">
                <h3 class="title">最近投资</h3>
                <ul class="data-list near-invest-list">
                    <li class="th">
                        <div class="col-name">项目名称</div>
                        <div class="col-money">投资金额</div>
                        <div class="col-gains">预期收益(仅供参考)</div>
                        <div class="col-invest-time">投资时间</div>
                        <div class="col-expire-time">还款时间</div>
                        <div class="col-status">进度情况</div>
                        <div class="col-ht">合同资料</div>
                    </li>
                    @foreach($projects as $project)
                        <li>
                            <div class="col-name">
                                {{--//TODO 项目详情链接--}}
                                <a href="#">{{ $project->projects_name }}</a>
                            </div>
                            <div class="col-money">{{ $project->invest_money  }}</div>
                            <div class="col-gains">

                            @if($project->id<309 && ($project->expected_return == 0))
                                请以老网站为准
                            @else
                                {{ $project->expected_return }}
                            @endif
                            </div>
                            <div class="col-invest-time">{{ $project->invest_time }}</div>
                            <div class="col-expire-time">{{ ($project->trade_finish_date??$project->trade_repayment_date)??'--' }}</div>
                            <div class="col-status">
                                {{ \App\Admin\Eloquent\Code::findByCodeAndTypeId($project->status, 'project_status')['name'] }}
                            </div>
                            {{-- TODO 合同模板下载 --}}
                            <div class="col-ht">
                            @if(empty($project->projects_file))
                                待生成
                            @else
                                <a class="blue" href="{{ action('UserCenter\UserCenterController@printTemplate',[$project->id]) }}" target="_bank">打印</a>
                            @endif
                            </div>
                        </li>
                    @endforeach
                </ul>
                <div class="uc-page-box text-right">
                    <span class="total">共 <em>{{$projects->total()}}</em> 条数据</span>
                    @for($i=1;$i<=$projects->lastPage();$i++)
                        <a class="{{$projects->currentPage()==$i?"current":""}}" href="{{ $projects->url($i) }}">{{ $i }}</a>
                    @endfor
                    <span>{{ $projects->currentPage() }}/{{ $projects->lastPage() }}页</span>
                </div>
            </div>

        </div>
    </div>
@endsection

@section('scripts')
    <script src="{{ asset('resources/web/js/index.js') }}"></script>
    <script type="text/javascript">
        $('.abc-title').hover(function() {
            $(this).find('.abc-box').css('width', '450px').stop(true,true).fadeIn();
        }, function() {
            $(this).find('.abc-box').fadeOut();
        });
    </script>
@endsection